package cn.csc.module.shop.controller.app.banner;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.framework.common.pojo.PageResult;
import cn.csc.module.shop.controller.admin.banner.vo.ShopBannerCreateReqVO;
import cn.csc.module.shop.controller.admin.banner.vo.ShopBannerPageReqVO;
import cn.csc.module.shop.controller.admin.banner.vo.ShopBannerRespVO;
import cn.csc.module.shop.controller.admin.banner.vo.ShopBannerUpdateReqVO;
import cn.csc.module.shop.controller.app.banner.vo.ShopBannerReqVO;
import cn.csc.module.shop.convert.banner.ShopBannerConvert;
import cn.csc.module.shop.dal.dataobject.banner.ShopBannerDO;
import cn.csc.module.shop.service.banner.ShopBannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.w3c.dom.stylesheets.LinkStyle;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import java.math.BigInteger;
import java.util.List;

import static cn.csc.framework.common.pojo.CommonResult.success;


@RestController
@RequestMapping("/shop/banner")
@Tag(name = "首页-banner信息")
@Slf4j
public class AppShopBannerController {

    @Resource
    private ShopBannerService shopBannerService;


    @GetMapping("/list")
    @ApiOperation("获得banner列表")
    @PermitAll
    public CommonResult<List<ShopBannerRespVO>> getList() {
        List<ShopBannerDO> list = shopBannerService.selectBannerList(null);
        return success(ShopBannerConvert.INSTANCE.convertList(list));
    }
    @GetMapping("/get")
    @ApiOperation("获得banner列表")
    @PermitAll
    public CommonResult<ShopBannerRespVO> getList(ShopBannerReqVO reqVO) {
        return success(ShopBannerConvert.INSTANCE.convert(shopBannerService.getBanner(reqVO.getId())));
    }
}
